<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        /**
         * 小程序授权事件记录
         */
        Schema::create('wxcallback_biz', function (Blueprint $table) {
            $table->id();
            $table->timestamp('receive_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('create_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->string('to_username', 64)->nullable(false)->default('');
            $table->string('appid', 64)->nullable(false)->default('');
            $table->string('msgtype', 64)->nullable(false)->default('');
            $table->string('event', 64)->nullable(false)->default('');
            $table->text('postbody')->nullable(false);
            $table->primary('id');
            $table->index('receive_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('wxcallback_biz');
    }
};
